package com.ys.controller;

import com.github.pagehelper.PageHelper;
import com.ys.mapper.DruMapper;
import com.ys.mapper.DrugsMapper;
import com.ys.mapper.DrugssMapper;
import com.ys.pojo.Drugs;
import com.ys.vo.PageVo;
import com.ys.vo.ResultVo;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class DrugsConller {
    @RequestMapping("/jinhuo/insertyao")
    public String insertyao(){
        return "/jinhuo/insertyao";
    }

    @Resource
    private DrugsMapper drugsMapper;
    @RequestMapping("/xuanzeyaopinshujuasd")
    @ResponseBody
    public ResultVo xuanzeyaopinshujuasd(){
        ResultVo resultVo = new ResultVo();
        resultVo.setObj(drugsMapper.selectss());
        return resultVo;
    }


    @RequestMapping("/huishoussssssss")
    public String zhuangeanyesss(){
        return "redirect:zhuangeanyesshuishous";
    }

    @RequestMapping("/zhuangeanyesshuishous")
    public String zhuangeanyesshuishous(){
        return "/richang/huishou";
    }


//    @RequestMapping("/zhuangeanye")
//    public String zhuangeanye(String ids,Integer a){
//        return "redirect:zhuangeanyesss";
//    }
//
//    @RequestMapping("/zhuangeanyesss")
//    public String zhuangeanyesss(){
//        return "/jinhuo/insertyaossss";
//    }



    @RequestMapping("/fanhuishangyiji")
    public String fanhuishangyiji(){
        return "/richang/yaopin";
    }

    @RequestMapping("/selecctsssssssssssssssssssss")
    @ResponseBody
        public ResultVo selecctsssssssssssssssssssss(String id,String name1,String pageNo,String pageSize,String name2
                ,String name3,String name4){
            ResultVo resultVo = new ResultVo();
            PageHelper.startPage(Integer.parseInt(pageNo),Integer.parseInt(pageSize));
            resultVo.setObj(new PageVo(drugsMapper.selectssssssssssssssssss(id,name1,name2,name3,name4)));
            return resultVo;
        }



    @RequestMapping(value = "/yichu", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ResultVo yichu(String id){
        ResultVo resultVo = new ResultVo();
        if(drugsMapper.yichu(id)){
            resultVo.setMsg("成功!");
        }else{
            resultVo.setMsg("失败");
        }
        return resultVo;

    }





    @RequestMapping(value = "/kucunyujing", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ResultVo kucunyujing(){
        ResultVo resultVo = new ResultVo();
        resultVo.setObj(drugsMapper.kucunyujing());
        return resultVo;

    }
}
